package com.bjsj.pro.tools;

/**
 * Created by Joe on 2018/7/3 0003 14:31.
 * 功能:防止两次点击时间间隔太短加载多个activity
 */

public class ButtonUtils
{
    private static long lastClickTime = 0;
    private static long DIFF = 1000;


    /**
     * 判断两次点击的间隔，如果小于800，则认为是多次无效点击
     *
     * @return
     */
    public static boolean isFastDoubleClick() {
        return isFastDoubleClick(DIFF);
    }


    /**
     * 判断两次点击的间隔，如果小于diff，则认为是多次无效点击
     *
     * @param diff
     * @return
     */
    public static boolean isFastDoubleClick(long diff) {
        long time = System.currentTimeMillis();
        long timeD = time - lastClickTime;
        if ( lastClickTime > 0 && timeD < diff) {

            return true;
        }
        lastClickTime = time;

        return false;
    }

}